
package net.atremmedia.gwt.actionjava.examples.graphics.samples;

import net.atremmedia.gwt.actionjava.examples.AJExample;
import net.atremmedia.gwt.actionjava.examples.frame.AJExampleOverview;
import actionjava.display.Graphics;
import actionjava.display.Shape;
import actionjava.display.Sprite;
import actionjava.geom.Color;

public class GraphicsExample3 extends AJExample
{
	public static final String NAME = "GraphicsExample 3";
	public static final String DESCRIPTION = "Description";
	public static final String EXAMPLE_SRC = "https://code.google.com/p/gwt-actionjava/source/browse/trunk/aj-examples/aj-examples-graphics/src/main/java/net/atremmedia/gwt/actionjava/examples/graphics/samples/GraphicsExample3.java";

	private Shape testShape1;
	private Shape testShape2;
	private Sprite testSprite;

	public GraphicsExample3(AJExampleOverview base)
	{
		super(NAME, DESCRIPTION, EXAMPLE_SRC, base);
	}

	@Override
	public void run()
	{
		testSprite = new Sprite();
		testSprite.setX(100);
		testSprite.setY(100);

		testShape1 = new Shape();
		Graphics graph = testShape1.getGraphics();
		graph.beginStroke("#000");
		graph.beginFill(Color.getRGBA(0xFF0000, 1));
		graph.drawCircle(0, 0, 50);
		graph.closePath();

		testShape2 = new Shape();
		graph = testShape2.getGraphics();
		graph.beginStroke("#000");
		graph.beginFill(Color.getRGBA(0xFFFF00, 1));
		graph.drawRect(0, 0, 300, 150);
		graph.closePath();
		testShape2.setMask(testShape1);

		testSprite.addChild(testShape2);
		addChild(testSprite);
	}
}
